package jdbctest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by Administrator on 2017/9/11.
 */
public class ConnectionUtils {
    public static Connection getConnection(){
        //1.加载驱动

        //2.连接数据库（对象）
        //需要三个参数（URL /用户名，密码）
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3307/my_table","root","123456");
            return conn;

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
